class Solution:
    def reverseLeftWords(self, s: str, n: int) -> str:
        return s[n:] + s[:n]
    
    def reverseLeftWords2(self, s: str, n: int) -> str:
        """
        若面试规定不允许使用字符串切片, 可以使用列表来实现
        """
        res = []
        for i in range(n, len(s) + n):
            res.append(s[i % len(s)])
        return "".join(res)

        


if __name__ == '__main__':
    solution = Solution()

    s = "abcdefg"
    k = 2
    print(s)
    print(solution.reverseLeftWords(s, k))

    s = "lrloseumgh"
    k = 6
    print(s)
    print(solution.reverseLeftWords(s, k))
    print("---------------------")

    s = "abcdefg"
    k = 2
    print(s)
    print(solution.reverseLeftWords2(s, k))

    s = "lrloseumgh"
    k = 6
    print(s)
    print(solution.reverseLeftWords2(s, k))
    print("Done!")